<template>
  <div class="app-container">
    <el-card class="box-card">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" >

          <el-form-item label="单位姓名" prop="departmentName">
            <el-input
              v-model="queryParams.departmentName"
              placeholder="请输入单位姓名"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>



          <el-form-item label="社会信用代码" prop="creditCodes">
            <el-input
              v-model="queryParams.creditCodes"
              placeholder="请输入统一社会信用代码"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>



          <el-form-item label="监管JDS" prop="representativeOffice">

            <el-select
              v-model="queryParams.representativeOffice"
              clearable
              placeholder="请选择监管JDS">
              <el-option
                v-for="dict in dict.type.yh_representative_office"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>



          <el-form-item label="上市情况" prop="listedSituation">
<!--            <el-input-->
<!--              v-model="queryParams.listedSituation"-->
<!--              placeholder="请输入上市情况"-->
<!--              clearable-->
<!--              @keyup.enter.native="handleQuery"-->
<!--            />-->
            <el-select v-model="queryParams.listedSituation" placeholder="请选择上市情况" clearable>
              <el-option
                v-for="dict in dict.type.yh_listed_situation"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>


      <div style="text-align: right;margin-right:-9px;">
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
      </div>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:enterprise:add']"
        >新增
        </el-button>
      </el-col>




      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:enterprise:remove']"
        >删除
        </el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['system:enterprise:import']"
        >导入</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:enterprise:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="enterpriseList" border @selection-change="handleSelectionChange" >
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="序号" align="center" :index="indexMethod" type="index" width="50"/>
      <el-table-column label="单位姓名" align="center" prop="departmentName" v-if="columns[0].visible"/>
      <el-table-column label="统一社会信用代码" align="center" prop="creditCodes" v-if="columns[1].visible"/>
      <el-table-column label="监管JDS" align="center" prop="representativeOffice" v-if="columns[2].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_representative_office" :value="scope.row.representativeOffice"/>
        </template>
      </el-table-column>
      <el-table-column label="菜单" align="center" prop="menus" v-if="columns[3].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_menus" :value="scope.row.menus"/>
        </template>
      </el-table-column>
      <el-table-column label="地址" align="center" prop="address" v-if="columns[4].visible"/>
      <el-table-column label="KJ主业务分公司地址" align="center" prop="forceMainAddress" v-if="columns[5].visible"/>
      <el-table-column label="机要地址" align="center" prop="confidentialAddress" v-if="columns[6].visible"/>
      <el-table-column label="属性" align="center" prop="properties" v-if="columns[7].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_properties" :value="scope.row.properties"/>
        </template>
      </el-table-column>
      <el-table-column label="所属管辖类别" align="center" prop="categoryOfJurisdiction" v-if="columns[8].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_category_of_jurisdiction" :value="scope.row.properties"/>
        </template>
      </el-table-column>
      <el-table-column label="上市情况" align="center" prop="listedSituation" v-if="columns[9].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_listed_situation" :value="scope.row.listedSituation"/>
        </template>
      </el-table-column>
      <el-table-column label="BM等级" align="center" prop="securityGrade" v-if="columns[10].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_security_grade" :value="scope.row.securityGrade"/>
        </template>
      </el-table-column>
      <el-table-column label="BM等级证书编号" align="center" prop="securityCertificateNo" v-if="columns[11].visible"/>
      <el-table-column label="承制资格" align="center" prop="grindersQualification" v-if="columns[12].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_grinders_qualification" :value="scope.row.grindersQualification"/>
        </template>
      </el-table-column>
      <el-table-column label="承制资格证书编号" align="center" prop="grindersQualificationNo" v-if="columns[13].visible"/>
      <el-table-column label="申办日期" align="center" prop="bidDate" v-if="columns[14].visible"/>
      <el-table-column label="续申日期" align="center" prop="renewedDate" v-if="columns[15].visible"/>
      <el-table-column label="到期日期" align="center" prop="dateDue" v-if="columns[16].visible"/>
      <el-table-column label="成立时间" align="center" prop="establishedTime" width="180" v-if="columns[17].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.establishedTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="企业简介" align="center" prop="enterpriseProfile" v-if="columns[18].visible"/>
      <el-table-column label="现阶段科研订货任务" align="center" prop="researchOrderTask" v-if="columns[19].visible"/>
      <el-table-column label="序号" align="center" prop="sequenceNumber" v-if="columns[20].visible"/>
      <el-table-column label="创建者" align="center" prop="createBy" v-if="columns[21].visible"/>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180" v-if="columns[22].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新者" align="center" prop="updateBy" v-if="columns[23].visible"/>
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180" v-if="columns[24].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" v-if="columns[25].visible"/>


      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"

            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:enterprise:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"

            @click="handleDelete(scope.row)"
            v-hasPermi="['system:enterprise:remove']"
          >删除
          </el-button>
          <el-button
            size="mini"
            type="text"

            @click="handleView(scope.row,scope.index)"
            v-hasPermi="['system:enterprise:query']"
          >详细</el-button>


          <el-button
            size="mini"
            type="text"
            @click="handleRelea(scope.row)"
            v-hasPermi="['system:leader:add']"
          >新增领导</el-button>

<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            @click="leaderView(scope.row,scope.index)"-->
<!--            v-hasPermi="['system:archives:query']"-->
<!--          >领导详细</el-button>-->


        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


</el-card>
    <!--导入 -->
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的承制单位数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="danger" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 添加或修改承制单位信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">承制单位信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <!--第一行-->
            <el-row>
              <el-col :span="8">
        <el-form-item label="单位姓名" prop="departmentName" label-width="35%">
          <el-input v-model="form.departmentName" placeholder="请输入单位姓名" style="width:90%;float:left"/>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="统一社会信用代码" prop="creditCodes" label-width="35%">
          <el-input v-model="form.creditCodes" placeholder="请输入统一社会信用代码" style="width:90%;float:left"/>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="监管JDS" prop="representativeOffice" label-width="35%">
          <el-select v-model="form.representativeOffice" placeholder="请选择监管JDS" style="width:90%;float:left" clearable>
            <el-option
              v-for="dict in dict.type.yh_representative_office"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
              </el-col>
            </el-row>

            <!--第2行-->
            <el-row>
              <el-col :span="8">
        <el-form-item label="菜单" prop="menus" label-width="35%">
          <el-select v-model="form.menus" placeholder="请选择菜单" style="width:90%;float:left" clearable>
            <el-option
              v-for="dict in dict.type.yh_menus"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="地址" prop="address" label-width="35%">
<!--          <el-input v-model="form.address" placeholder="请输入地址" style="width:90%;float:left"/>-->
          <el-cascader
            v-model="selectedOptions"
            :options="options"
            filterable
            clearable

            @change="handleChange"
            style="width:90%;float:left"
          />
        </el-form-item>
              </el-col>


              <el-col :span="8">
                <el-form-item label="详细地址" prop="address" label-width="35%">
                  <el-input v-model="form.detailedAddress" placeholder="请输入详细地址" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="8">
                <el-form-item label="经营范围" prop="forceMainAddress" label-width="35%">
                  <el-input v-model="form.businessNatures" placeholder="请输入经营范围" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="承制范围" prop="forceMainAddress" label-width="35%">
                  <el-input v-model="form.productionScope" placeholder="请输入承制范围" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="KJ主业务分公司地址" prop="forceMainAddress" label-width="35%">
          <el-input v-model="form.forceMainAddress" placeholder="请输入KJ主业务分公司地址" style="width:90%;float:left"/>
        </el-form-item>
              </el-col>
            </el-row>

            <!--第3行-->
            <el-row>
              <el-col :span="8">
        <el-form-item label="机要地址" prop="confidentialAddress" label-width="35%">
          <el-input v-model="form.confidentialAddress" placeholder="请输入机要地址" style="width:90%;float:left"/>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="属性" prop="properties" label-width="35%">
          <el-select v-model="form.properties" placeholder="请选择属性" style="width:90%;float:left" clearable>
            <el-option
              v-for="dict in dict.type.yh_properties"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="所属管辖类别" prop="categoryOfJurisdiction" label-width="35%">
          <el-select v-model="form.categoryOfJurisdiction" placeholder="请选择所属管辖类别" style="width:90%;float:left" clearable>
            <el-option
              v-for="dict in dict.type.yh_category_of_jurisdiction"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
              </el-col>
            </el-row>

            <!--第4行-->
            <el-row>
              <el-col :span="8">
        <el-form-item label="上市情况" prop="listedSituation" label-width="35%">
          <el-select v-model="form.listedSituation" placeholder="请选择上市情况" style="width:90%;float:left" clearable>
            <el-option
              v-for="dict in dict.type.yh_listed_situation"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="BM等级" prop="securityGrade" label-width="35%">
          <el-select v-model="form.securityGrade" placeholder="请选择BM等级"  style="width:90%;float:left" clearable>
            <el-option
              v-for="dict in dict.type.yh_security_grade"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="BM等级证书编号" prop="securityCertificateNo" label-width="35%">
          <el-input v-model="form.securityCertificateNo" placeholder="请输入BM等级证书编号"  style="width:90%;float:left"/>
        </el-form-item>
              </el-col>
            </el-row>

            <!--第5行-->
            <el-row>
              <el-col :span="8">
        <el-form-item label="承制资格" prop="grindersQualification" label-width="35%">
          <el-select v-model="form.grindersQualification" placeholder="请选择承制资格"  style="width:90%;float:left" clearable>
            <el-option
              v-for="dict in dict.type.yh_grinders_qualification"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="承制资格证书编号" prop="grindersQualificationNo" label-width="35%">
          <el-input v-model="form.grindersQualificationNo" placeholder="请输入承制资格证书编号" style="width:90%;float:left"/>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="申办日期" prop="bidDate" label-width="35%">
<!--          <el-input v-model="form.bidDate" placeholder="请输入申办日期" style="width:90%;float:left"/>-->
          <el-date-picker clearable
                          v-model="form.bidDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择申办日期"
                          style="width:90%;float:left">
          </el-date-picker>
        </el-form-item>
              </el-col>
            </el-row>

            <!--第6行-->
            <el-row>
              <el-col :span="8">
        <el-form-item label="续申日期" prop="renewedDate" label-width="35%">
<!--          <el-input v-model="form.renewedDate" placeholder="请输入续申日期" style="width:90%;float:left"/>-->
          <el-date-picker clearable
                          v-model="form.renewedDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择续申日期"
                          style="width:90%;float:left">
          </el-date-picker>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="到期日期" prop="dateDue" label-width="35%">
<!--          <el-input v-model="form.dateDue" placeholder="请输入到期日期" style="width:90%;float:left"/>-->
          <el-date-picker clearable
                          v-model="form.dateDue"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择到期日期"
                          style="width:90%;float:left">
          </el-date-picker>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="成立时间" prop="establishedTime" label-width="35%">
          <el-date-picker clearable
                          v-model="form.establishedTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择成立时间"
                          style="width:90%;float:left">
          </el-date-picker>
        </el-form-item>
              </el-col>
            </el-row>

            <!--第6行-->
            <el-row>
              <el-col :span="8">
        <el-form-item label="科研订货任务" prop="researchOrderTask" label-width="35%" >
          <el-input v-model="form.researchOrderTask" placeholder="请输入现阶段科研订货任务" style="width:90%;float:left"/>
        </el-form-item>
              </el-col>

              <el-col :span="8">
        <el-form-item label="序号" prop="sequenceNumber" label-width="35%">
          <el-input v-model="form.sequenceNumber" placeholder="请输入序号" style="width:90%;float:left"/>
        </el-form-item>
              </el-col>
            </el-row>


            <el-col :span="24">
                <el-form-item label="企业简介" label-width="11.5%">
                  <el-input v-model="form.enterpriseProfile" type="textarea" placeholder="请输入内容" style="width:97.8%;float:left"/>
<!--                 <file-upload v-model="form.enterpriseProfile" />-->
<!--                  <el-upload-->
<!--                    ref="upload"-->
<!--                    :limit="1"-->
<!--                    accept=".pdf"-->
<!--                    :action="upload.url"-->
<!--                    :headers="upload.headers"-->
<!--                    :file-list="upload.fileList"-->
<!--                    :on-progress="handleFileUploadProgress"-->
<!--                    :on-success="handleFileSuccess"-->
<!--                    :auto-upload="false">-->
<!--                    <el-button slot="trigger" size="small" type="primary">选取文件</el-button>-->
<!--                    <el-button style="margin-left: 10px;" size="small" type="success" :loading="upload.isUploading" @click="submitUpload">上传到服务器</el-button>-->
<!--                    <div slot="tip" class="el-upload__tip">只能上传pdf文件，且不超过5M</div>-->
<!--                  </el-upload>-->
                </el-form-item>
            </el-col>


<!--        <el-form-item label="备注" prop="remark">-->
<!--          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>-->
<!--        </el-form-item>-->
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>



    <!--=======================================================================================-->


    <!-- 添加或修改承制单位领导信息对话框 -->
    <el-dialog :title="relea.title" :visible.sync="relea.open" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="12%">
<!--        <el-form-item label="承制单位ID" prop="manufacturerId">-->
<!--          <el-input v-model="form.manufacturerId" placeholder="请输入承制单位ID" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="统一社会信用代码" prop="creditCodes">-->
<!--          <el-input v-model="form.creditCodes" placeholder="请输入统一社会信用代码" />-->
<!--        </el-form-item>-->
        <el-form-item label="主要领导姓名" prop="leaderName">
          <el-input v-model="form.leaderName" placeholder="请输入主要领导姓名" />
        </el-form-item>
        <el-form-item label="主要领导职务" prop="leaderPosition">
          <el-input v-model="form.leaderPosition" placeholder="请输入主要领导职务" />
        </el-form-item>
        <el-form-item label="主要领导办公电话" prop="leaderBusinessPhone">
          <el-input v-model="form.leaderBusinessPhone" placeholder="请输入主要领导办公电话" />
        </el-form-item>
        <el-form-item label="主要领导移动电话" prop="leaderMobilePhone">
          <el-input v-model="form.leaderMobilePhone" placeholder="请输入主要领导移动电话" />
        </el-form-item>

<!--        <el-form-item label="备注" prop="remark">-->
<!--          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />-->
<!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="releasubmitForm">确 定</el-button>
        <el-button @click="releaCancel">取 消</el-button>
      </div>
    </el-dialog>


  </div>
</template>



<style>
  .el-header, .el-footer {
    background-color: #FFFFFF;
    color: #333;
    text-align: left;
    line-height: 60px;
    font-style: oblique;

  }

  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-main {
    background-color: #FFFFFF;
    color: #333;
    text-align: center;
    line-height: 160px;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }

  .el-dialog__title {
    /*color: #1ab394;*/
    font-weight: bold;
    font-size: 25px;
  }
  .input_text{
    background-color: #efefef;
    border-color: #efefef;
    border-style:solid;
    border-top-width:0px;
    border-right-width:0px;
    border-bottom-width:1px;
    border-left-width:0px;

    /*border-top-width: 0px;*/
    /*border-left-width: 0px;*/
    /*border-right-width: 0px;*/
    /*border-bottom-width: 1px;*/
  }
</style>

<script>

  // 导入省市区数据组件
  import { provinceAndCityData,CodeToText, TextToCode } from 'element-china-area-data';
  import {
    listLeader,
    getLeader,
    delLeader,
    addLeader,
    updateLeader
  } from "@/api/system/leader";
  import {
    listEnterprise,
    getEnterprise,
    delEnterprise,
    addEnterprise,
    updateEnterprise
  } from "@/api/module/ls/enterprise";

  import { getToken } from "@/utils/auth";

  export default {
    name: "Enterprise",
    dicts: ['yh_security_grade',
      'yh_listed_situation',
      'yh_representative_office',
      'yh_menus',
      'yh_properties',
      'yh_category_of_jurisdiction',
      'yh_grinders_qualification'
     ],

    data() {
      return {
        //携带当前行的参数数组
        carryCurrentRowCode: {
          creditCodes: "",
        },
        //城市选项
        options: provinceAndCityData,
        selectedOptions: [],
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 承制单位信息表格数据
        enterpriseList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          departmentName: null,
          creditCodes: null,
          representativeOffice: null,
          menus: null,
          address: null,
          forceMainAddress: null,
          confidentialAddress: null,
          properties: null,
          categoryOfJurisdiction: null,
          listedSituation: null,
          securityGrade: null,
          securityCertificateNo: null,
          grindersQualification: null,
          grindersQualificationNo: null,
          bidDate: null,
          renewedDate: null,
          dateDue: null,
          establishedTime: null,
          enterpriseProfile: null,
          researchOrderTask: null,
          sequenceNumber: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          note1: null,
          note2: null,
          note3: null,
          note4: null,
          note5: null,
          note6: null,
          note7: null,
          note8: null,
          note9: null,
          note10: null
        },
        // 用户查询参数
        view:{
          // 是否显示弹出层（用户查询）
          open: false,
          // 弹出层标题（用户查询）
          title: "",
        },
        // 关联查询参数
        relea:{
          // 是否显示弹出层（用户查询）
          open: false,
          // 弹出层标题（用户查询）
          title: "",
        },
        // 列信息
        columns: [
          {key: 0, label: `单位姓名`, visible: true},
          {key: 1, label: `统一社会信用代码`, visible: true},
          {key: 2, label: `监管JDS`, visible: true},
          {key: 3, label: `菜单`, visible: false},
          {key: 4, label: `地址`, visible: false},
          {key: 5, label: `KJ主业务分公司地址`, visible: false},
          {key: 6, label: `机要地址`, visible: true},
          {key: 7, label: `属性`, visible: true},
          {key: 8, label: `所属管辖类别`, visible: false},
          {key: 9, label: `上市情况`, visible: true},
          {key: 10, label: `BM等级`, visible: false},
          {key: 11, label: `BM等级证书编号`, visible: false},
          {key: 12, label: `承制资格`, visible: false},
          {key: 13, label: `承制资格证书编号`, visible: false},
          {key: 14, label: `申办日期`, visible: true},
          {key: 15, label: `续申日期`, visible: true},
          {key: 16, label: `到期日期`, visible: false},
          {key: 17, label: `成立时间`, visible: false },
          {key: 18, label: `企业简介`, visible: false},
          {key: 19, label: `现阶段科研订货任务`, visible: false},
          {key: 20, label: `序号`, visible: false},
          {key: 21, label: `创建者`, visible: false},
          {key: 22, label: `创建时间`, visible: false},
          {key: 23, label: `更新者`, visible: false},
          {key: 24, label: `更新时间`, visible: false},
          {key: 24, label: `备注`, visible: false}
        ],
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
        // 用户导入参数
        upload: {
          // 是否显示弹出层（用户导入）
          open: false,
          // 弹出层标题（用户导入）
          title: "",
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部
          headers: { Authorization: "Bearer " + getToken() },
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/ls/enterprise/importData"
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询承制单位信息列表 */
      getList() {
        this.loading = true;
        listEnterprise(this.queryParams).then(response => {
          this.enterpriseList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      handleChange (value) {
        console.log(value)
        this.getCodeToText(null,value)
      },
      getCodeToText (codeStr, codeArray) {
        if (null === codeStr && null === codeArray) {
          return null;
        } else if (null === codeArray) {
          codeArray = codeStr.split(",");
        }
        let address = "";
        switch (codeArray.length) {
          case 1:
            address += CodeToText[codeArray[0]];
            break;
          case 2:
            address += CodeToText[codeArray[0]] + "/" + CodeToText[codeArray[1]];
            break;
          default:
            break;
        }
        this.form.address = address
        return address;
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 取消按钮
      viewCancel() {
        this.view.open = false;
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          departmentName: null,
          creditCodes: null,
          representativeOffice: null,
          menus: null,
          address: null,
          forceMainAddress: null,
          confidentialAddress: null,
          properties: null,
          categoryOfJurisdiction: null,
          listedSituation: null,
          securityGrade: null,
          securityCertificateNo: null,
          grindersQualification: null,
          grindersQualificationNo: null,
          bidDate: null,
          renewedDate: null,
          dateDue: null,
          establishedTime: null,
          enterpriseProfile: null,
          researchOrderTask: null,
          sequenceNumber: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          note1: null,
          note2: null,
          note3: null,
          note4: null,
          note5: null,
          note6: null,
          note7: null,
          note8: null,
          note9: null,
          note10: null
        };
        this.resetForm("form");
      },
      /** 下载模板操作 */
      importTemplate() {
        this.download('/ls/enterprise/importTemplate', {
        }, `user_template_${new Date().getTime()}.xlsx`)
      },
      /** 导入按钮操作 */
      handleImport() {
        this.upload.title = "用户导入";
        this.upload.open = true;
      },
      // 文件上传中处理
      handleFileUploadProgress(event, file, fileList) {
        this.upload.isUploading = true;
      },
      // 文件上传成功处理
      handleFileSuccess(response, file, fileList) {
        this.upload.open = false;
        this.upload.isUploading = false;
        this.$refs.upload.clearFiles();
        this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
        this.getList();
      },
      // 提交上传文件
      submitFileForm() {
        this.$refs.upload.submit();
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      indexMethod(index) {
        index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
        return index
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.selectedOptions=[];
        this.open = true;
        this.title = "添加承制单位信息";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getEnterprise(id).then(response => {
          this.form = response.data;
          this.selectedOptions = TextToCode[this.form.address.split('/')[0]][this.form.address.split('/')[1]].code;
          this.open = true;
          this.title = "修改承制单位信息";
        });
      },
      /** 详细按钮操作 */
      handleView(row) {
        // const id = row.id || this.ids
        // getEnterprise(id).then(response => {
        //   this.form = response.data;
        //   this.view.open = true;
        //   this.view.title = "承制单位信息查看";
        // });
        const id = row.id;
        this.$router.push({ path:"/jiben/enterprise_detail", query: {id}});
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              updateEnterprise(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addEnterprise(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      // 文件下载处理
      handleDownload(row) {
        var name = row.fileName;
        var url = row.filePath;
        var suffix = url.substring(url.lastIndexOf("."), url.length);
        const a = document.createElement('a')
        a.setAttribute('download', name + suffix)
        a.setAttribute('target', '_blank')
        a.setAttribute('href', url)
        a.click()
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        const i=row.departmentName || this.is;
        this.$modal.confirm('是否确认删除单位名称为"' + i + '"的数据项？').then(function () {
          return delEnterprise(ids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {
        });
      },
      /** 关联按钮操作 */
      handleRelea(row) {
        this.reset();
        console.log(row)
        const id = row.id || this.ids
        getEnterprise(id).then(response => {
          this.form = response.data;
          this.form.manufacturerId=row.id;
          this.form.creditCodes=row.creditCodes
        });
        this.relea.open = true;
        this.relea.title = "新增领导信息";
      },
      /** 新增领导按钮操作 */
      releasubmitForm(){
        this.$refs["form"].validate(valid => {
          if (valid) {
            updateEnterprise(this.form).then(response => {
              this.getList();
            });
            addLeader(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.relea.open = false;
            });
          }
        });
      },
      // 取消按钮
      releaCancel() {
        this.relea.open = false;
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('system/enterprise/export', {
          ...this.queryParams
        }, `enterprise_${new Date().getTime()}.xlsx`)
      }
    }
  };


</script>
